// 公共日期格式化方法
const timeFormatting = function(timeDate, category) {
    // timeDate 时间戳 category 需要的格式
    let date = new Date(parseInt(timeDate) * 1000);
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    var hours = date.getHours();
    var minutes = date.getMinutes();
    var seconds = date.getSeconds();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    if (hours >= 0 && hours <= 9) {
        hours = "0" + hours;
    }
    if (minutes >= 0 && minutes <= 9) {
        minutes = "0" + minutes;
    }
    if (seconds >= 0 && seconds <= 9) {
        seconds = "0" + seconds;
    }
    switch (category) {
    case "y":
        date = year + "-" + month + "-" + strDate;
        break;
    case "yh":
        date = year + "年" + month + "月" + strDate + "日" + hours + "时";
        break;
    case "yhdms":
        date = year + "-" + month + "-" + strDate + " " + hours + ":" + minutes + ":" + seconds;
        break;
    case "yd":
        date = year + "年" + month + "月" + strDate + "日";
        break;
    case "day":
        date = month + "月" + strDate + "日";
        break;
    case "hdm":
        date = strDate + "天" + hours + "时" + minutes + "分";
        break;
    default:
        date = month + "月" + strDate + "日" + hours + "时";
    }
    return date;
}
export default {
    timeFormatting
};